package com.bluestone.context;

import java.util.ArrayList;
import java.util.List;

import com.bluestone.scripts.TestCase;
import com.bluestone.scripts.TestSuite;
import com.bluestone.util.Util;

public class TestSuiteContext extends ContextBase {
	
	public TestSuiteContext(TestSuite suite){
		this.testSuite = suite;
		this.setId(testSuite.getId());
		this.createTestcaseContext();
	}
	private TestSuite testSuite = null;
	
	private void createTestcaseContext(){
		List testcases = testSuite.getTestcases();
		for(int i=0; i< testcases.size(); i++){
			TestCase testcase = (TestCase) testcases.get(i);
			testcase.setId(""+i);
			TestCaseContext context = new TestCaseContext(testcase);
			testcaseContexts.add(context);
		}

		
	}
	
	ArrayList<TestCaseContext> testcaseContexts = new ArrayList<TestCaseContext>();

	public TestSuite getTestSuite() {
		return testSuite;
	}
	
	public TestCaseContext getTestCaseContext(TestCase testcase){
		TestCaseContext context = null;
		for(int i=0; i< testcaseContexts.size(); i++){
			TestCaseContext temp = (TestCaseContext)testcaseContexts.get(i);
			if(testcase.getId().equalsIgnoreCase(temp.getId())){
				context = temp;
				break;
			}
		}
		return context;
	}
	
	public ProjectContext getProjectContext(){
		return ProjectContext.getInstance(null);
	}



}
